<!--<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>-->
<!--<%@ taglib prefix="s" uri="/struts-tags"%>-->
<!--<%-->
<!--String path = request.getContextPath();-->
<!--String basePath = request.getScheme() + "://"-->
<!--+ request.getServerName() + ":" + request.getServerPort()-->
<!--+ path + "/";-->
<!--%>-->

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <base href="<%=basePath%>">

    <title>编辑用户</title>

    <meta name="pragma" content="no-cache">
    <meta name="cache-control" content="no-cache">
    <meta name="expires" content="0">
    <link th:insert="~{views/script :: tiancai}"/>
</head>

<body>
<section class="info-section">
    <form id="form" method="post" th:action="@{/userUpdate}">
        <table>
            <tr>
                <td class="text-title">用户名：</td>
                <td class="text-content">
                    <input type="hidden" name="id" th:value="${userVO.getId()}">
                    <input type="text" name="userName" th:value="${userVO.getUserName()}"
                           class="easyui-textbox theme-textbox-radius"
                           data-options="required:true,validType:'length[6,20]'">
                </td>
            </tr>

            <tr style="display:${empty userVO ? 'table-row' : 'none'};">
                <td class="text-title">密码：</td>
                <td class="text-content">
                    <input type="password" name="password" th:value="${userVO.getPassword() }"
                           class="easyui-textbox theme-textbox-radius"
                           data-options="required:true,validType:'length[6,20]'">
                </td>
            </tr>

            <tr>
                <td class="text-title">联系电话：</td>
                <td class="text-content">
                    <input type="text" name="phone" th:value="${userVO.getPhone() }"
                           class="easyui-textbox theme-textbox-radius" data-options="required:true">
                </td>
            </tr>
            <tr>
                <td class="text-title">电子邮箱：</td>
                <td class="text-content">
                    <input type="text" name="email" th:value="${userVO.getEmail() }"
                           class="easyui-textbox theme-textbox-radius" data-options="required:true,validType:'email'">
                </td>
            </tr>
            <tr>
                <td class="text-title">排序编号：</td>
                <td class="text-content">
                    <input type="text" name="sortNum" th:value="${userVO.getSortNum() }"
                           class="easyui-textbox theme-textbox-radius" data-options="required:true">
                </td>
            </tr>
            <tr>
                <td class="text-title">用户状态：</td>
                <td class="text-content">
                    <select name="status" class="easyui-combobox theme-textbox-radius">
<!--                        <select class="form-control" name="department.id">-->
<!--                            <option th:selected="${userVO.getStatus()==1}" th:each="${userVO}"-->
<!--                                    th:text="${userVO.get}" th:value="${dept.getId}">1-->
<!--                            </option>-->

<!--                        </select>-->
                        <option th:value="${userVO.getStatus()==1} ? '正常':' ' ">正常</option>
                        <option th:value="${userVO.getStatus()==0} ?'禁用':' ' ">禁用</option>
                        <option th:value="${userVO.getStatus()==2}  ?'已删除':' ' ">已删除</option>

                    </select>
                </td>
            </tr>
            <tr>
                <td class="text-title">描述信息：</td>
                <td class="text-content">
                    <textarea class="theme-textbox-radius" rows="5" cols="20"
                              name="userNote">[[ ${userVO.userNote } ]]</textarea></td>
            </tr>
            <!-- 因为用户关联信息不需要修改，但是如果没有把这些信息传递给服务器端，hibernate对数据进行更新时就会把对应条目设置为null值 -->

            <tr style="display: none;">
                <td colspan="2">
<!--                    <input type="hidden" name="userVO.roleIds" th:value="${userVO.getSortNum()}">-->
<!--                    <input type="hidden" name="createBy" th:value="${userVO.getCreateBy()}">-->
<!--                    <input type="hidden" name="createTime" th:value="${userVO.getCreateTime()}">-->
                </td>
            </tr>
            <tr>
                <td colspan="2" style="text-align: center;margin-top: 10px;">
<!--                    <a href="javascript:void(0);" id="saveBtn" class="easyui-linkbutton button-primary">保存</a>-->
                    <input type="submit" class="easyui-linkbutton button-primary" th:value="保存" style="width: 50px;height: 30px;color: #0ec228" />

                    <a href="javascript:void(0);" id="resetBtn" class="easyui-linkbutton button-danger">重置</a>
                </td>
            </tr>
        </table>
    </form>
</section>
<script type="text/javascript" th:inline="none">
    $(function () {
        //重置按钮
        $("#resetBtn").on("click", function (event) {
            $("#form").form("reset");
        });
        //保存按钮
        $("#saveBtn").on("click", function (event) {
            $("#form").form("submit", {
                url: "/userUpdate",
                onSubmit: function () {
                    //对表单进行数据校验,如果未通过校验，返回false，阻止表单提交
                    return $(this).form("validate");

                },
                success: function (data) {
                    //data未服务器端返回的字符串数据，eval将字符串数据转换为json对象
                    data = eval("(" + data + ")");
                    if (data.success) {
                        parent.closeTopWindow();
                    }
                }
            });
        });
    });
</script>
</body>
</html>
